package com.onpositive.funkytable.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;

import com.onpositive.funkytable.IControlFactory;
import com.onpositive.funkytable.IFunkyComposite;
import com.onpositive.funkytable.IFunkyControl;
import com.onpositive.funkytable.IFunkyTextControl;

public class SWTControlFactory implements IControlFactory{

	@Override
	public IFunkyTextControl createTextElement(String text) {
		FunkyText funkyText = new FunkyText();
		funkyText.setText(text);
		return funkyText;
	}

	@Override
	public IFunkyComposite createComposite(int orientation) {
		FunkyComposite mc=new FunkyComposite();
		mc.setOrientation(orientation);
		return mc;
	}

	@Override
	public IFunkyControl createViewer(Object value) {
		return createTextElement(value.toString());
	}
	
	static FunkyStyle sectionStyle=new FunkyStyle();
	static FunkyStyle style1=new FunkyStyle();
	static FunkyStyle style2=new FunkyStyle();
	
	static {
		sectionStyle.fgcolor=Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
		sectionStyle.bgcolor=Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
		style1.fgcolor=Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
		style1.bgcolor=Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
		style2.fgcolor=Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
		style2.bgcolor=Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
	}

	@Override
	public FunkyStyle sectionStyle() {
		return sectionStyle;
	}

	@Override
	public FunkyStyle style(int a) {
		if (a%2==0){
			return style1;
		}
		return style2;
	}

}
